package com.woman.beautylive.data.repository;

import android.net.Uri;
import android.support.annotation.NonNull;

import com.woman.beautylive.util.Const;
import com.woman.beautylive.util.L;

/**
 * 数据源工厂类。
 * Created by huanzhang on 2016/4/11.
 */
public class NewSourceFactory {

    private static ISource source;

    //Should not be instantiable
    private NewSourceFactory() {

    }

    /**
     * 获取数据源。
     */
    public static ISource create() {
        if (source == null) {
            synchronized (NewSourceFactory.class) {
                if (source == null) {
                    source = new NewRetrofitSource();
//                    source = new FakeSource();
                }
            }
        }
        return source;
    }

    public static String wrapPath(String path) {
        if (!path.startsWith("http")) {
            path = Const.MAIN_HOST_URL + path;
        }
        L.e("huan",path);
        return path;
    }

    public static Uri wrapPathToUri(@NonNull String path) {
        return Uri.parse(wrapPath(path));
    }


    /**
     * 按照与服务器的约定判断一个指定的数字代表男性还是女性。
     *
     * @return 如果是男性则返回true, 否则返回false。
     */
    public static boolean isMale(int gender) {
        return gender == 0;
    }
}
